package com.db.chat.server;

/**
 * All avaliable commands
 */

public enum CommandEnum {
    UNKNOWN_COMMAND(null),
    CHID("/chid"),
    HIST("/hist"),
    SND("/snd"),
    CHROOM("/chroom"),
    ISALIVE("/isAlive");

    private String command;

    CommandEnum(String value) {
        this.command = value;
    }

    /**
     *
     * @param s - string to convert to CommandEnum
     * @return returns CommandEnum if one exists, Null otherwise
     */
    public static  CommandEnum fromString(String s) {
        for (CommandEnum command : CommandEnum.values()) {
            if (command.command != null && command.command.equals(s)) {
                return command;
            }
        }
        return UNKNOWN_COMMAND;
    }
}
